package tech.heiming.aps.scheduler.deadline;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.optaplanner.core.api.domain.solution.PlanningEntityCollectionProperty;
import org.optaplanner.core.api.domain.solution.PlanningScore;
import org.optaplanner.core.api.domain.solution.PlanningSolution;
import org.optaplanner.core.api.domain.valuerange.CountableValueRange;
import org.optaplanner.core.api.domain.valuerange.ValueRangeFactory;
import org.optaplanner.core.api.domain.valuerange.ValueRangeProvider;
import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore;

import java.util.List;

/**
 * @author heimingz
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@PlanningSolution
public class ScheduleTable {
    private Long timeslotRange;

    @PlanningEntityCollectionProperty
    private List<OrderSlice> orderSlices;

    @PlanningScore
    private HardSoftScore score;

    public ScheduleTable(Long timeslotRange, List<OrderSlice> orderSlices) {
        this.timeslotRange = timeslotRange;
        this.orderSlices = orderSlices;
    }

    @ValueRangeProvider(id = "timeslotRange")
    public CountableValueRange<Long> getTimeslotRange() {
        return ValueRangeFactory.createLongValueRange(0, timeslotRange);
    }
}
